package kr.hkit.androidcomplete01.chapter11;

import java.util.ArrayList;

import kr.hkit.androidcomplete01.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class EditSelectEx extends Activity {
	EditText mEdit;
	int length;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.editselect);
		
		mEdit = (EditText)findViewById(R.id.edit_select);
		
	}
	
	public void mOnClick(View v){
		String edit;
		int blank;
		switch(v.getId()){
		
		case R.id.home:
			mEdit.setSelection(0);
			break;
			
		case R.id.end:
			mEdit.setSelection(mEdit.getText().length());
			break;
			
		case R.id.selblock:
			mEdit.setSelection(3, 10);

			/*edit = mEdit.getText().toString().trim();
			blank = edit.indexOf("abc");
			Toast.makeText(EditSelectEx.this, blank, Toast.LENGTH_SHORT).show();

			if (mEdit.getText().toString().trim().equals(""))
				Toast.makeText(EditSelectEx.this,
						mEdit.getText().toString().trim(), Toast.LENGTH_SHORT)
						.show();*/
			break;
			
		case R.id.selall:
			mEdit.selectAll();
			break;
			
		case R.id.getsel:
			int start = mEdit.getSelectionStart();
			int end = mEdit.getSelectionEnd();
			
			Toast.makeText(EditSelectEx.this, "start = "+ start + ", end = " + end, Toast.LENGTH_SHORT).show();
			break;
		}
	}
}
